package com.cat.greedyAlgorithm;

/**
*   @description https://leetcode.cn/problems/remove-adjacent-almost-equal-characters/
*   @author 曲大人的喵
*   @create 2025/8/25 10:11
*   @since JDK17
*/

public class Solution28 {
    public int removeAlmostEqualCharacters(String word) {
        int n = word.length(), ans = 0;
        for (int i = 1; i < n; i++) {
            if (Math.abs(word.charAt(i) - word.charAt(i - 1)) <= 1) {
                ans++;
                i++;
            }
        }

        return ans;
    }
}
